<template>
	<div>
		<!-- 理赔详细资料 -->
		<el-form
		 v-loading.fullscreen.lock="fullLoading" 
		 element-loading-text="拼命加载中"
		    label-width="140px" :model="dataForm" :rules="rules" ref="dataForm">
			<el-card class="box-card">
				<div slot="header" class="clearfix">
					<span>诊疗信息</span>
				</div>
				<el-row>
					<el-col :span="8">
						<el-form-item label="就诊医院:" prop="hospital">
							<el-input v-model="dataForm.hospital" placeholder=""></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="就诊类型:" prop="treatmentType">
							<el-select v-model="dataForm.treatmentType">
								<el-option v-for="item in Consts.treatmentTypeList" :key="item.value"
									:label="item.label" :value="item.value">
								</el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="20">
						<el-form-item label="治疗描述:" prop="treatmentRecord">
							<el-input type="textarea" :rows="4" placeholder="请输入被保险人治疗描述"
								v-model="dataForm.treatmentRecord">
							</el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="8">
						<el-form-item label="垫付:" prop="payAdvanceFlag">
							<el-radio-group v-model="dataForm.payAdvanceFlag">
								<el-radio label="1">是</el-radio>
								<el-radio label="0">否</el-radio>
							</el-radio-group>
						</el-form-item>
					</el-col>
					<el-col :span="8" v-if="dataForm.payAdvanceFlag == 1">
						<el-form-item label="垫付金额:" prop="payAdvanceAmountYuan">
							<el-input v-model="dataForm.payAdvanceAmountYuan" placeholder=""></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row v-if="dataForm.payAdvanceFlag == 1">
					<el-col :span="8">
						<el-form-item label="垫付时间:" prop="payAdvanceTime">
							<el-date-picker v-model="dataForm.payAdvanceTime" type="datetime" placeholder="选择日期时间"
								value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="垫付公司:" prop="payAdvanceCompany">
							<el-input type="text" placeholder="请输入垫付公司" v-model="dataForm.payAdvanceCompany">
							</el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row v-if="dataForm.payAdvanceFlag == 1">
					<el-col :span="8">
						<el-form-item label="垫付协议:" prop="payAdvanceAgreementUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="payAdvanceAgreementUpload"
								:data="payAdvanceAgreement" :file-list="payAdvanceAgreementFileList"
								:on-preview="handlePreview" :http-request="submitFileUpload"
								:on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="垫付凭证:" prop="payAdvanceCertificateUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="payAdvanceCertificateUpload"
								:data="payAdvanceCertificate" :file-list="payAdvanceCertificateFileList"
								:on-preview="handlePreview" :http-request="submitFileUpload"
								:on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-form-item label="是否涉及二次治疗:" prop="treatAgainFlag">
						<el-radio-group v-model="dataForm.treatAgainFlag">
							<el-radio label="1">是</el-radio>
							<el-radio label="0">否</el-radio>
						</el-radio-group>
					</el-form-item>
				</el-row>
			</el-card>
			<el-card class="box-card" style="margin-top: 20px">
				<div slot="header" class="clearfix">
					<span>理赔单据</span>
				</div>
				<el-row>
					<el-form-item label="发票:" prop="invoiceUploadFlag">
						<el-upload class="upload-demo" drag action="#" ref="invoiceUpload" :data="invoice"
							:file-list="invoiceFileList" :on-preview="handlePreview" :http-request="submitFileUpload"
							:on-remove="handleFileRemove" multiple>
							<i class="el-icon-upload"></i>
							<div class="el-upload__text">
								将文件拖到此处或<em>点击上传</em>
							</div>
						</el-upload>
					</el-form-item>
				</el-row>
				<el-row>
					<el-col :span="11">
						<el-form-item label="发票金额:" prop="invoiceAmountYuan">
							<el-input v-model="dataForm.invoiceAmountYuan" placeholder=""></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10">
						<el-form-item label="诊断证明:" prop="diagnosticCertificateUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="diagnosticCertificateUpload"
								:data="diagnosticCertificate" :file-list="diagnosticCertificateFileList"
								:on-preview="handlePreview" :http-request="submitFileUpload"
								:on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="病例:" prop="hospitalCaseUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="hospitalCaseUpload"
								:data="hospitalCase" :file-list="hospitalCaseFileList" :on-preview="handlePreview"
								:http-request="submitFileUpload" :on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="10">
						<el-form-item label="误工证明:" prop="proofOfDelayUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="proofOfDelayUpload" :data="proofOfDelay"
								:file-list="proofOfDelayFileList" :on-preview="handlePreview"
								:http-request="submitFileUpload" :on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
					<el-col :span="10">
						<el-form-item label="其他:" prop="otherUploadFlag">
							<el-upload class="upload-demo" drag action="#" ref="otherUpload" :data="other" :file-list="otherFileList"
								:on-preview="handlePreview" :http-request="submitFileUpload"
								:on-remove="handleFileRemove" multiple>
								<i class="el-icon-upload"></i>
								<div class="el-upload__text">
									将文件拖到此处或<em>点击上传</em>
								</div>
							</el-upload>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="21">
						<el-form-item label-width="200px" label="死亡家属实际索要金额:" prop="familyWantAmountYuan">
							<el-input v-model="dataForm.familyWantAmountYuan" placeholder=""></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-form-item label-width="200px" label="收到理赔资料原件时间:" prop="getFileTime">
						<el-date-picker v-model="dataForm.getFileTime" type="datetime" placeholder="选择日期时间"
							value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss">
						</el-date-picker>
					</el-form-item>
					<!-- <el-form-item>
            <label style="color: red">*理赔单据已上传齐全</label>
          </el-form-item> -->
				</el-row>
				<el-row>
					<el-form-item label-width="200px" label="理赔材料递交保险公司日期:" prop="sendCorpTime">
						<el-date-picker v-model="dataForm.sendCorpTime" type="datetime" placeholder="选择日期时间"
							value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss">
						</el-date-picker>
					</el-form-item>
				</el-row>
				<el-row type="flex" justify="center">
					<el-form-item>
						<el-button @click="goBack()">返回</el-button>
						<el-button type="primary" @click="save()" :loading="saveLoading">保存</el-button>
					</el-form-item>
				</el-row>
			</el-card>
		</el-form>
		<PreviewFile ref="previewFileRef"></PreviewFile>
	</div>
</template>

<script>
	import {
		isMoney
	} from "@/utils/validate";
	import PreviewFile from '@/components/previewFile.vue';

	export default {
		data() {
			// 自定义规则
			var validateMoney = (rule, value, callback) => {
				if(!value){
					callback();
					return
				}
				if (!isMoney(value)) {
					callback(new Error("金额格式错误(仅可保留两位小数)"));
				} else {
					callback();
				}
			};
			var validateInvoiceFile = (rule, value, callback) => {
				callback();
				// if (value <= 0) {
				// 	callback(new Error("请添加发票"));
				// } else {
				// 	callback();
				// }
			};
			var validateDiagnosticCertificateFile = (rule, value, callback) => {
				callback();
				// if (value <= 0) {
				// 	callback(new Error("请添加诊断证明"));
				// } else {
				// 	callback();
				// }
			};
			var validatePayAdvanceAgreementFile = (rule, value, callback) => {
				callback();
				// if(this.dataForm.payAdvanceFlag == 0){
				// 	callback();
				// }
				//    if (value <= 0) {
				// 	callback(new Error("请添加垫付协议"));
				//    } else {
				// 	callback();
				//    }
			};
			var validatePayAdvanceCertificateFile = (rule, value, callback) => {
				callback();
				// if(this.dataForm.payAdvanceFlag == 0){
				// 	callback();
				// }

				//     if (value <= 0) {
				//       callback(new Error("请添加垫付凭证"));
				//     } else {
				//       callback();
				//     }
			};
			var validateHospitalCaseFile = (rule, value, callback) => {
				callback();
				// if (value <= 0) {
				// 	callback(new Error("请添加病例"));
				// } else {
				// 	callback();
				// }
			};
			var validateProofOfDelayFile = (rule, value, callback) => {
				callback();
				// if (value <= 0) {
				// 	callback(new Error("请添加误工证明"));
				// } else {
				// 	callback();
				// }
			};
			var validateOtherFile = (rule, value, callback) => {
				callback();
				// if (value <= 0) {
				// 	callback(new Error("请添加其他"));
				// } else {
				// 	callback();
				// }
			};
			return {
				fullLoading: false,
				saveLoading: false,
				invoice: {
					attachment: "invoice",
					entityType: "settlement",
				},
				diagnosticCertificate: {
					attachment: "diagnosticCertificate",
					entityType: "settlement",
				},
				hospitalCase: {
					attachment: "hospitalCase",
					entityType: "settlement",
				},
				proofOfDelay: {
					attachment: "proofOfDelay",
					entityType: "settlement",
				},
				other: {
					attachment: "other",
					entityType: "settlement",
				},
				payAdvanceAgreement: {
					attachment: "payAdvanceAgreement",
					entityType: "settlement",
				},
				payAdvanceCertificate: {
					attachment: "payAdvanceCertificate",
					entityType: "settlement",
				},
				invoiceFileList: [], // 历史上传的数据,做展示用
				diagnosticCertificateFileList: [], // 历史上传的数据,做展示用
				payAdvanceAgreementFileList: [], // 历史上传的数据,做展示用
				payAdvanceCertificateFileList: [], // 历史上传的数据,做展示用
				hospitalCaseFileList: [], // 历史上传的数据,做展示用
				proofOfDelayFileList: [], // 历史上传的数据,做展示用
				otherFileList: [], // 历史上传的数据,做展示用
				files: [], // 新上传的数据
				deleteFiles: [], // 记录删除的 历史数据
				dataForm: {
					id: "",
					csId: "",
					hospital: "",
					treatmentType: "",
					treatmentRecord: "",
					payAdvanceFlag: "",
					payAdvanceAmountYuan: "",
					payAdvanceTime: "",
					payAdvanceCompany: "",
					invoiceAmountYuan: "",
					familyWantAmountYuan: "",
					getFileTime: "",
					sendCorpTime: "",
					treatAgainFlag: "",
					invoiceUploadFlag: 0,
					diagnosticCertificateUploadFlag: 0,
					payAdvanceAgreementUploadFlag: 0,
					payAdvanceCertificateUploadFlag: 0,
					hospitalCaseUploadFlag: 0,
					proofOfDelayUploadFlag: 0,
					otherUploadFlag: 0,
					files: [],
				},
				csId: "",
				rules: {
					hospital: [{
						required: false,
						message: "请输入就诊医院",
						trigger: "blur"
					}, ],
					treatmentType: [{
						required: false,
						message: "请选择就诊类型",
						trigger: "change"
					}, ],
					treatmentRecord: [{
						required: false,
						message: "请输入治疗描述",
						trigger: "blur"
					}, ],
					payAdvanceFlag: [{
						required: false,
						message: "请选择是否垫付",
						trigger: "change"
					}, ],
					payAdvanceAmountYuan: [{
							validator: validateMoney,
							trigger: "blur"
						},
						{
							required: false,
							message: "请输入垫付金额",
							trigger: "blur"
						},
					],
					treatAgainFlag: [{
						required: false,
						message: "请选择是否涉及二次治疗",
						trigger: "change",
					}, ],
					invoiceAmountYuan: [{
							validator: validateMoney,
							trigger: "blur"
						},
						{
							required: false,
							message: "请输入发票金额",
							trigger: "blur"
						},
					],
					familyWantAmountYuan: [{
							validator: validateMoney,
							trigger: "blur"
						},
						{
							required: false,
							message: "请输入死亡家属实际索要金额",
							trigger: "blur",
						},
					],
					getFileTime: [{
						required: false,
						message: "请选择收到理赔资料原件时间",
						trigger: "blur",
					}, ],
					sendCorpTime: [{
						required: false,
						message: "请选择理赔材料递交保险公司日期",
						trigger: "change",
					}, ],
					payAdvanceTime: [{
						required: false,
						message: "请选择垫付时间",
						trigger: "change",
					}, ],
					payAdvanceCompany: [{
						required: false,
						message: "请输入垫付公司",
						trigger: "change",
					}, ],
					invoiceUploadFlag: [{
						required: false,
						validator: validateInvoiceFile,
						trigger: "change"
					}, ],
					diagnosticCertificateUploadFlag: [{
						required: false,
						validator: validateDiagnosticCertificateFile,
						trigger: "change",
					}, ],
					payAdvanceAgreementUploadFlag: [{
						required: false,
						validator: validatePayAdvanceAgreementFile,
						trigger: "change",
					}, ],
					payAdvanceCertificateUploadFlag: [{
						required: false,
						validator: validatePayAdvanceCertificateFile,
						trigger: "change",
					}, ],
					hospitalCaseUploadFlag: [{
						required: false,
						validator: validateHospitalCaseFile,
						trigger: "change",
					}, ],
					proofOfDelayUploadFlag: [{
						required: false,
						validator: validateProofOfDelayFile,
						trigger: "change",
					}, ],
					otherUploadFlag: [{
						required: false,
						validator: validateOtherFile,
						trigger: "change"
					}, ],
				},
			};
		},
		components: {
			  PreviewFile
		},
		props: ["claimSettlement"],
		activated() {
			console.log("========", this.claimSettlement);
		},
		methods: {
			init: function() {
				this.$http({
					url: this.$http.adornUrl("/claim/treatmentinfo/info"),
					method: "post",
					contentType: "form",
					params: this.$http.adornParams({
						csId: this.claimSettlement.id,
					}),
				}).then(({
					data
				}) => {
					console.log("data", data);
					if (data && data.code === 0 && data.data.id) {
						if(this.$refs.payAdvanceAgreementUpload){
							this.$refs.payAdvanceAgreementUpload.clearFiles();
						}
						if(this.$refs.payAdvanceCertificateUpload){
							this.$refs.payAdvanceCertificateUpload.clearFiles();
						}
						if(this.$refs.invoiceUpload){
							this.$refs.invoiceUpload.clearFiles();
						}
						if(this.$refs.diagnosticCertificateUpload){
							this.$refs.diagnosticCertificateUpload.clearFiles();
						}
						if(this.$refs.hospitalCaseUpload){
							this.$refs.hospitalCaseUpload.clearFiles();
						}
						if(this.$refs.proofOfDelayUpload){
							this.$refs.proofOfDelayUpload.clearFiles();
						}
						if(this.$refs.otherUpload){
							this.$refs.otherUpload.clearFiles();
						}
						this.dataForm = Object.assign(this.dataForm, data.data);
						this.dataForm.treatAgainFlag = this.dataForm.treatAgainFlag + "";
						// 处理上传文件
						this.invoiceFileList = [];
						this.diagnosticCertificateFileList = [];
						this.payAdvanceAgreementFileList = [];
						this.payAdvanceCertificateFileList = [];
						this.hospitalCaseFileList = [];
						this.proofOfDelayFileList = [];
						this.otherFileList = [];
						this.deleteFiles = [];
						this.files = [];
						if (this.dataForm.files) {
							for (let i = 0; i < this.dataForm.files.length; i++) {
								let item = this.dataForm.files[i];
								let filename = item.filePath;
								const lastIndex = filename.lastIndexOf('_');
								const dotIndex = filename.lastIndexOf('.');
								const newName = `${filename.slice(0, lastIndex)}${filename.slice(dotIndex)}`; 
								let obj = {
									name: newName,
									url: item.filePath,
									id: item.id,
									fileType: item.fileType,
									attachment: item.attachment,
								};
								switch (item.attachment) {
									case "invoice":
										this.invoiceFileList.push(obj);
										break;
									case "diagnosticCertificate":
										this.diagnosticCertificateFileList.push(obj);
										break;
									case "payAdvanceAgreement":
										this.payAdvanceAgreementFileList.push(obj);
										break;
									case "payAdvanceCertificate":
										this.payAdvanceCertificateFileList.push(obj);
										break;
									case "hospitalCase":
										this.hospitalCaseFileList.push(obj);
										break;
									case "proofOfDelay":
										this.proofOfDelayFileList.push(obj);
										break;
									case "other":
										this.otherFileList.push(obj);
										break;
								}
							}
							this.dataForm.invoiceUploadFlag = this.invoiceFileList.length;
							this.dataForm.diagnosticCertificateUploadFlag =
								this.diagnosticCertificateFileList.length;
							this.dataForm.payAdvanceAgreementUploadFlag =
								this.payAdvanceAgreementFileList.length;
							this.dataForm.payAdvanceCertificateUploadFlag =
								this.payAdvanceCertificateFileList.length;
							this.dataForm.hospitalCaseUploadFlag =
								this.hospitalCaseFileList.length;
							this.dataForm.proofOfDelayUploadFlag =
								this.proofOfDelayFileList.length;
							this.dataForm.otherUploadFlag = this.otherFileList.length;
						}
					}
				});
			},
			save: function() {
				console.log("this.dataForm", this.dataForm);
				this.saveLoading = true;
				this.dataForm.csId = this.claimSettlement.id;
				this.dataForm.files = this.files;
				this.dataForm.deleteFiles = this.deleteFiles;
				this.$refs["dataForm"].validate((valid) => {
					console.log("valid==", valid);
					if (valid) {
						this.$http({
							url: this.$http.adornUrl("/claim/treatmentinfo/save"),
							method: "post",
							data: this.$http.adornData(this.dataForm),
						}).then(({
							data
						}) => {
							this.saveLoading = false;
							if (data && data.code === 0) {
								this.$message({
									message: "操作成功",
									type: "success",
									duration: 1500,
									onClose: () => {
										this.init();
										this.$emit(
											"callBack",
											null,
											true
										);
									},
								});
							} else {
								this.$message.error(data.msg);
							}
						});
					} else {
						this.saveLoading = false;
					}
				});
			},
			goBack: function() {
				this.$router.go(-1); // 返回上一层
			},
			submitFileUpload: function(req) {
				this.fullLoading = true;
				console.log("===> "+req);
				let that = this;
				let reader = new FileReader();
				reader.readAsDataURL(req.file);
				reader.onload = function() {
					let newFileName = that.renameFile(req.file.name, req.file.uid);
					that
						.$http({
							url: that.$http.adornUrl("/migrantWorkers/file/upload"),
							method: "post",
							data: JSON.stringify({
								file: reader.result,
								path: newFileName
							}),
						})
						.then(({
							data
						}) => {
							that.fullLoading = false;
							if (data && data.code === 0) {
								let fileParams = {
									fileName: newFileName,
									attachment: req.data.attachment,
									fileType: req.file.type,
									filePath: newFileName,
									entityType: req.data.entityType,
									description: "",
									uid: req.file.uid,
								};
								console.log("gggg==-==", fileParams);
								that.files.push(fileParams);
								that.modifyUploadFlag("upload", req.data.attachment);
								that.$message.success("上传成功");
							} else if (data && data.msg) {
								that.$message.error(data.msg);
							}
						}).catch(error => {
            // 失败：统一处理错误
              that.$message.error("上传文件异常");
              that.fullLoading = false;
              console.error("上传文件error:", error);
              that[req.data.attachment+`FileList`] = that[req.data.attachment+`FileList`].filter(item => {
                if (item.uid === req.file.uid) {
                  return false;
                }
                return true;
              });
          });
				};
			},
			handlePreview: function (req) {
			  this.fullLoading = true;
			  console.log("handlePreview", req);
			  let that = this;
			  let filePath = "";
			  let fileType = "";
			  if (req.status === "success") {
			    filePath = req.url;
			    fileType = req.fileType;
			  } else if (req.status === "ready") {
			    filePath = that.renameFile(req.raw.name, req.raw.uid);
			    fileType = req.raw.type;
			  }
			  console.log("fileType",fileType)
			  let type = "preview";
			  // if(fileType.indexOf("image") != -1 || fileType.indexOf("pdf") != -1){
				 //  type = "download";
			  // }
			  this.$http({
			    url: this.$http.adornUrl("/migrantWorkers/file/download"),
			    method: "post",
			    data: this.$http.adornData(
			      {
			        path: filePath,
			      },
			      false,
			      "json"
			    ),
			  }).then(({ data }) => {
				  that.fullLoading = false;
			    console.log("data", JSON.stringify(data));
			    if (data && data.code === 0) {
					if(type = "preview"){
						//预览
						that.$refs.previewFileRef.showDialog(fileType, data.data, filePath);
					}else{
						that.Base64Util.downloadFile(data.data, filePath, fileType);
					}
			    } else if (data && data.msg) {
			      that.$message.error(data.msg);
			    }
			  });
			},
			handleFileRemove: function(req) {
				console.log("handleFileRemove", req);
				let that = this;
				let status = req.status;
				let filePath = "";
				if (status === "success") {
					filePath = req.url;
				} else if (status === "ready") {
					filePath = that.renameFile(req.raw.name, req.raw.uid);
				}
				that
					.$http({
						url: that.$http.adornUrl("/migrantWorkers/file/delete"),
						method: "post",
						data: JSON.stringify({
							path: filePath
						}),
					})
					.then(({
						data
					}) => {
						if (data && data.code === 0) {
							if (status === "success") {
								that.deleteFiles.push(req.id);
								that.modifyUploadFlag("delete", req.attachment);
							} else if (status === "ready") {
								that.files.some((item, i) => {
									// 删除fileList中对应的元素
									if (item.uid === req.raw.uid) {
										that.modifyUploadFlag("delete", item.attachment);
										that.files.splice(i, 1);
									}
								});
							}
							that.$message.success("文件删除成功");
						} else if (data && data.msg) {
							that.$message.error(data.msg);
						}
					});
				console.log("this.dataForm.files", this.dataForm.files);
				console.log("this.files", this.files);
			},
			modifyUploadFlag: function(oper, attachment) {
				console.log("modifyUploadFlag", oper, attachment);
				let flagVal = 0;
				let that = this;
				switch (oper) {
					case "upload":
						flagVal = 1;
						break;
					case "delete":
						flagVal = -1;
						break;
					default:
						flagVal = 0;
						break;
				}
				switch (attachment) {
					case "invoice":
						that.dataForm.invoiceUploadFlag += flagVal;
						break;
					case "diagnosticCertificate":
						that.dataForm.diagnosticCertificateUploadFlag += flagVal;
						break;
					case "payAdvanceAgreement":
						that.dataForm.payAdvanceAgreementUploadFlag += flagVal;
						break;
					case "payAdvanceCertificate":
						that.dataForm.payAdvanceCertificateUploadFlag += flagVal;
						break;
					case "hospitalCase":
						that.dataForm.hospitalCaseUploadFlag += flagVal;
						break;
					case "proofOfDelay":
						that.dataForm.proofOfDelayUploadFlag += flagVal;
						break;
					case "other":
						that.dataForm.otherUploadFlag += flagVal;
						break;
				}
			},
			renameFile: function(originFileName, fileUID) {
				if (originFileName == null || originFileName === undefined) {
					return null;
				}
				let fileNameSplit = originFileName.split(".");
				let fileName = "";
				for (let i = 0; i < fileNameSplit.length - 1; i++) {
					if (i < fileNameSplit.length - 2) {
						fileName = fileName + fileNameSplit[i] + ".";
					} else {
						fileName = fileName + fileNameSplit[i];
					}
				}
				// 跟文件名加上时间
				fileName = fileName + "_" + fileUID;
				let fileExtendName = fileNameSplit[fileNameSplit.length - 1];
				return fileName + "." + fileExtendName;
			},
		},
	};
</script>

<style>
</style>
